(function ($) {
    $('#addJob2').on('click', function () {
        if ($(this).attr('data-status') != 0) {
            return false
        }
        $(this).attr('data-status', 1)
        var title = $('.addNews__title').val(),
            fileUrl = $('.addNews__hide').val(),
            content = $('#addNewsDetailTextarea').val(),
            userInfo = cacheGet('userInfo');
        setTimeout(function () {
            $('.addNews__alert').fadeOut()
        }, 1500)
        if (userInfo == 'undefined' || userInfo.token == 'undefined') {
            $('.addNews__alert').fadeIn().text('账号未登录！');
            return false;
        }

        if (title == '') {
            $('.addNews__alert').fadeIn().text('请输入标题')
            return false
        }

        if (fileUrl == '') {
            $('.addNews__alert').fadeIn().text('请选择文件')
            return false
        }
        if (content == '') {
            $('.addNews__alert').fadeIn().text('请编辑内容')
            return false
        }
        var data = {
            app_access: 'qSoiKwpWVge4TkaryH6MKvOdceGt7ZMaF20g8H0cnXI',
            token: userInfo.token,
            type: userInfo.type,
            title: title,
            thumb: fileUrl,
            content: content

        }

        $.ajax({
            url: '/api/news/add',
            type: 'post',
            data: data,
            dataType: 'json',
            success: function (res) {
                $('.addNews__alert').fadeIn().text('发布成功!')
                setTimeout(function () {
                    window.location.href = "../index.html"
                }, 1000)
            },
            fail: function () {
                $('.addNews__alert').fadeIn().text('发布失败!')
            }
        })

    });

    $('#fengmian .pic').on('click', function () {


        MC.API.UpPic(function (url) {
            $('#fengmian .img').attr('src', url);
            $('#addNews__hide').val(url);
            $('#addNewsDetail .bFileDiv .spantitle').hide();
        });
    });

})(jQuery)